package it.xiuxian.personcenter.presenter

import com.lzy.okgo.OkGo
import it.xiuxian.lib.base.BaseBean
import it.xiuxian.lib.base.BasePresenter
import it.xiuxian.lib.base.ILoadBind
import it.xiuxian.lib.http.CallBackOption
import it.xiuxian.lib.http.HttpConfig
import it.xiuxian.lib.utils.AESUtils
import it.xiuxian.personcenter.activity.UpdateLoginActivity
import org.json.JSONObject

class UpdateLoginActivityPresenter:BasePresenter<UpdateLoginActivity>() {

    fun updataLoginPwd(old_password:String,password:String){
        val json1 = JSONObject()
        json1.put("oldpass",old_password)
            .put("newpass",password)
        val s = AESUtils.encryptAES_ECB(json1.toString())
        OkGo.post<BaseBean<String>>(HttpConfig.BASE_URL+"/appuserpassword/updatePassWord")
            .params("encrypt", s)
            .execute(object : CallBackOption<BaseBean<String>>() {}.loadBind(mView as UpdateLoginActivity).execute(
                object : ILoadBind<BaseBean<String>> {
                    override fun excute(bean: BaseBean<String>) {

                        if(bean.code==0){
                            (mView as UpdateLoginActivity).setUI(bean.msg)
                        }
                    }
                }
            ))

    }
}